package cn.net.cfss.fgbp.provider.manage.config;

import cn.net.cfss.fgbp.provider.manage.solr.MyMappingSolrConverter;
import org.apache.solr.client.solrj.SolrClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.data.solr.core.mapping.SimpleSolrMappingContext;

@Configuration
public class SolrConfig {

    @Bean
    @ConditionalOnMissingBean(SolrTemplate.class)
    public SolrTemplate solrTemplate(SolrClient solrClient) {
        SolrTemplate solrTemplate=new SolrTemplate(solrClient);
        MyMappingSolrConverter myMappingSolrConverter=new MyMappingSolrConverter(new SimpleSolrMappingContext());
        solrTemplate.setSolrConverter(myMappingSolrConverter);
        return solrTemplate;
    }
}
